package com.xianlai.microcosm_log_example

import android.os.Bundle
import com.xianlai.microcosm_log.FlutterLog
import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

    val TAG = "MainActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        FlutterLog.d(TAG, "onCreate")
        val start = System.currentTimeMillis();
        //测试多个线程同时log的情况
        for (i in 0 until 3) {
            object : Thread() {
                var count = 0;
                override fun run() {
                    super.run()
                    name = "Thread${i}"
                    while (System.currentTimeMillis() - start < 1000) {
                        FlutterLog.v("Thread${i}", "${++count}")
                        sleep(10)
                    }
                }
            }.start()
        }
    }

    override fun onStart() {
        super.onStart()
        FlutterLog.i(TAG, "onStart")
    }

    override fun onResume() {
        super.onResume()
        FlutterLog.w(TAG, "onResume")
    }

    override fun onPause() {
        super.onPause()
        FlutterLog.v(TAG, "onPause")
    }

    override fun onStop() {
        super.onStop()
        FlutterLog.e(TAG, "onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        FlutterLog.e(TAG, "onDestroy")
    }
}
